import "pkl:test"

x: Int = 1

res1: module = module

res2: module = this

res3: module = (this) { x = 2 }

res4: module? = null

res5: List<module> = List(module, (module) { x = 2 })

res6: List<module> = fun(this)

res6a: module = res6[0]

function fun(m: module): List<module> = List((m) { x = 2 })

class Bad {
  res7: module = "abc"

  res8: module = new Person {}

  res9: module? = new Person {}

  res10: List<module> = List(new Person {})
}

class Person

res7 = test.catch(() -> new Bad {}.res7)

res8 = test.catch(() -> new Bad {}.res8)

res9 = test.catch(() -> new Bad {}.res9)

res10 = test.catch(() -> new Bad {}.res10)

output {
  // force eval but don't render to prevent recursion
  value =
    let (r1 = res1)
      let (r2 = res2)
        let (r3 = res3)
          let (r4 = res4)
            let (r5 = res5)
              let (r6 = res6)
                let (r6a = res6a)
                  let (r7 = res7)
                    let (r8 = res8)
                      let (r9 = res9)
                        let (r10 = res10)
                          new Dynamic { result = "ok" }
}
